<template>
  <div class="msg_notification_list">
    <el-container>
      <el-header>
        <header-item :item="tips"></header-item>
      </el-header>
      <el-main>
        <main-tools-item :toolsType="toolsType" :searchType="searchType" @search='search'></main-tools-item>
        <main-spare-item @onClick=''></main-spare-item>
        <main-data-list-item :columns="columns" :dataList="dataList" :pager="page" @batchDelete='batchDelete' @currentChange='currentChange'>
        </main-data-list-item>
      </el-main>
    </el-container>
  </div>
</template>

<script>
  import {
    get,
    post,
    pat,
    del,
    common,
    getRefresh
  } from "../../../../api/api";
  import headerItem from "./../../Commons/headerItem.vue";
  import mainToolsItem from "./../../Commons/mainToolsItem.vue";
  import mainSpareItem from "./../../Commons/mainSpareItem.vue";
  import mainDataListItem from "./../../Commons/mainDataListItem.vue";
  export default {
    components: {
      headerItem,
      mainToolsItem,
      mainSpareItem,
      mainDataListItem
    },
    data() {
      return {
        tips: "通知消息",
        toolsType: 2,
                searchType: 11,
        sels: [],
        page: {
          pageNo: 1,
          limit: 10,
          sizes: [10, 50, 100],
          total: 0
        },
        columns: [
           // {
          //   prop: 'id',
          //   label: '系统消息id',
          //   width: '',
          //   align: 'center'
          // },
          {
            prop: 'title',
            label: '消息标题',
            width: '200',
            align: 'center',
          },
          {
            prop: 'profile',
            label: '消息简介',
            width: '200px',
            align: 'center'
          },
          {
            prop: 'content',
            label: '消息内容',
            width: '200px',
            align: 'center'
          },
          {
            prop: 'contentType',
            label: '消息内容类型',
            width: '200px',
            align: 'center'
          },
          {
            prop: 'status',
            label: '状态',
            width: '120',
            align: 'center'
          },
          {
            prop: 'createUser',
            label: '创建用户',
            width: '',
            align: 'center'
          },
          {
            prop: 'createTime',
            label: '创建时间',
            width: '',
            align: 'center'
          }
        ],
        dataList: [],
        loading: false,
        param: {
          title: '',
          size: '10',
          current: '1'
        },
      };
    },
    methods: {
      //--------查询----------
      search(val) {
        this.param ={}
        this.param.title = "";
        this.param.title = val.title;
        this.getMsgNotificationList();
      },
      //--------删除----------
      batchDelete(val){
      },
      //-------分页----------
      currentChange(val) {
        this.param.current = "";
        this.param.current = val
        this.getMsgNotificationList();
      },
      //获取list列表
      getMsgNotificationList() {
        return new Promise((resolve, reject) => {
          var param = {};
          for (let key in this.param) {
            if (this.param[key]!=null && this.param[key].length != 0) {
              param[key] = this.param[key]
            }
          }
          post("/userInfo/selectXasMsgNotification", param).then(resdata => {
            let self = function () {
              this.$router.push({ path: '/home'});
            }.bind(this);
            let error = function () {
              alert(resdata.msg)
            }.bind(this);
            let success = function () {
              if (resdata.code == 1) {
                this.dataList = resdata.data.records;
                this.page.total = resdata.data.total;
              }
            }.bind(this);
            common(self)(error)(success)(resdata);
            resolve();
          });
        });
      },
    },
    async mounted() {
      await this.getMsgNotificationList();
    },
    watch: {
    }
  };

</script>

<style lang="scss">
  .msg_notification_list {
    background-color: white;
    font-size: 1.8rem;
    width: 100%;
    height: 100%;
    .el-container {
      height: 100%;
      .el-header,
      .el-footer {
        background-color: #F9FAFE;
        color: #333;
        text-align: center;
        line-height: 50px;
        height: 50px !important;
        .header-child {
          height: 50px;
          width: 100%;
          text-align: left;
          padding-left: 20px;
          background-color: #cbe9eb;
          border-bottom: 1px solid black;
          box-shadow: 0 5px 5px 0 rgba(0, 0, 0, 0.5);
        } 
      }
      .el-main {
        box-shadow: 0 5px 5px 0px rgba(0, 0, 0, 0.5); // margin: 10px 20px;
        margin: 10px;
        background-color: #fff;
        color: #333;
        text-align: center;
        height: 100%;
      }
    }
  }

</style>
